package handlers

import (
	"cron-go/configs/error_code"
	"cron-go/internal/pkg/crontab/job"

	"github.com/go-liam/util/response"
)

type RefreshCrontab struct {
	Data interface{}
}

func (s *RefreshCrontab) GetData() *response.APIResponse {
	s.Bind()
	return &response.APIResponse{Code: error_code.Success, Message: error_code.MsSuccess, Data: s.Data}
}

func (s *RefreshCrontab) Bind() {
	// page := &response.Pagination{PageSize: 50000, Current: 1}
	// r := &response.ListParameter{WhereSt: " and `status` =1 ", OrderSt: " order by id "}
	// ls, _ := new(dao.TaskDao).FindMulti(page, r)
	// //bind
	// baseModels := make([]*models.TaskMysqlModel, 0)
	// for _, item := range ls {
	// 	i := new(models.TaskMysqlModel)
	// 	i.ID = item.ID
	// 	i.Spec = item.Spec
	// 	baseModels = append(baseModels, i)
	// }
	// task.Service.BatchAdd(baseModels)
	num := job.InitTaskJob()
	data := make(map[string]interface{})
	data["num"] = num
	s.Data = data
}
